using UnityEngine;

namespace Exploder.Demo
{
	public class PanelChairBomb : UseObject
	{
		public ExploderObject Exploder;

		public GameObject ChairBomb;

		public AudioSource SourceExplosion;

		public AudioClip ExplosionSound;

		public Light Flash;

		private int flashing;

		public override void Use()
		{
			base.Use();
			Exploder.transform.position = ChairBomb.transform.position;
			Exploder.ExplodeSelf = false;
			Exploder.UseForceVector = false;
			Exploder.Radius = 10f;
			Exploder.TargetFragments = 300;
			Exploder.Force = 30f;
			Exploder.ExplodeRadius(OnExplode);
		}

		private void OnExplode(float timeMS, ExploderObject.ExplosionState state)
		{
			if (state == ExploderObject.ExplosionState.ExplosionStarted)
			{
				SourceExplosion.PlayOneShot(ExplosionSound);
				Flash.gameObject.transform.position = ChairBomb.transform.position;
				Flash.gameObject.transform.position += Vector3.up;
				flashing = 10;
			}
		}

		private void Update()
		{
			if (flashing > 0)
			{
				Flash.intensity = 5f;
				flashing--;
			}
			else
			{
				Flash.intensity = 0f;
			}
		}
	}
}
